const mysql = require('mysql2')
const config = require('../config/index')
const db = mysql.createPool({
    host: config.sqlOption.host,
    user: config.sqlOption.user,
    password: config.sqlOption.password,
    database: config.sqlOption.database
})

const query = (sql, params) => {
    return new Promise((reslove, reject) => {
        db.query(sql, params, (err, result) => {
            if (err) return reject(err)
            reslove(result)
        })
    })
}
module.exports = query